/**
 * 企业成员相关类型定义
 */

/**
 * 成员信息接口
 */
export interface Member {
  id: string;
  url?: string;
  name: string;
  display_name: string;
  email?: string;
  avatar?: string;
  status: 'active' | 'inactive' | 'pending';
  role?: string;
  department?: string;
  position?: string;
  phone?: string;
  created_at?: number;
  updated_at?: number;
  last_login_at?: number;
  is_admin?: boolean;
  is_owner?: boolean;
  permissions?: string[];
}

/**
 * 成员查询参数接口
 */
export interface MemberQueryParams {
  name?: string; // 用户名搜索
  display_name?: string; // 显示名称搜索
  email?: string; // 邮箱搜索
  status?: 'active' | 'inactive' | 'pending'; // 状态筛选
  role?: string; // 角色筛选
  department?: string; // 部门筛选
  is_admin?: boolean; // 是否管理员
  page_index?: number; // 页码（0-based）
  page_size?: number; // 每页大小
  sort_by?: string; // 排序字段
  sort_order?: 'asc' | 'desc'; // 排序方向
}

/**
 * 成员列表响应接口
 */
export interface MemberListResponse {
  page_size: number;
  page_index: number;
  total: number;
  values: Member[];
}

/**
 * 成员统计信息接口
 */
export interface MemberStatistics {
  total: number;
  active: number;
  inactive: number;
  pending: number;
  admins: number;
  departments: {
    name: string;
    count: number;
  }[];
  roles: {
    name: string;
    count: number;
  }[];
}

/**
 * 成员操作类型
 */
export type MemberAction = 'view' | 'edit' | 'delete' | 'activate' | 'deactivate' | 'promote' | 'demote';

/**
 * 成员批量操作参数
 */
export interface MemberBatchOperation {
  action: MemberAction;
  memberIds: string[];
  data?: Partial<Member>;
}

/**
 * 成员导入数据接口
 */
export interface MemberImportData {
  name: string;
  display_name: string;
  email: string;
  role?: string;
  department?: string;
  position?: string;
  phone?: string;
}

/**
 * 成员导入结果接口
 */
export interface MemberImportResult {
  success: number;
  failed: number;
  errors: {
    row: number;
    message: string;
    data: MemberImportData;
  }[];
}